// @/api/user.js
import { get, post } from '@/utils/request'

// 获取小区列表 无参数
export const getCommunityList = (params) => {
    return get('/community/list', params)
}


// 添加小区 {name:"XX小区"}
export const addCommunity = (data) => {
    return post('/community/add', data)
}

// 更新小区 {id:"x",name:"XX小区"}
export const updateCommunity = (data) => {
    return post('/community/update', data)
}

// 删除小区 {id:"x"}
export const deletCommunity = (id) => {
    return post('/community/delete', { id })
}
// 添加用户 {community_id:"x",name:"xxx",phone:"1xxxxxxxxxx"}
export const addUser = (data) => {
    return post('/users/add', data)
}
// 批量添加用户 {community_id:"x",list:[{name:"xxx",phone:"1xxxxxxxxxx"},...]}
export const addUserBatch = (data) => {
    return post('/users/batchAdd', data)
}
// 获取用户列表 带分页,支持community_id查询
/*返回示例：
{
    "code": 200,
    "data": {
        "list": [
            {
                "id": "52",
                "community_id": "2",
                "name": "测试员",
                "phone": "13655412565",
                "is_winner": "0",
                "is_preset": "0",
                "created_at": "1752733477",
                "updated_at": "1752733477",
                "community": "文昌璟苑"
        },...]
    }
}

*/
export const getUserList = (params) => {
    return get('/users/alist', params)
}
// 设置内定 {id:"x"}
export const setUserPreset = (data) => {
    return post('/users/setWinner', data)
}
//获取活动列表 无参数 无分页
export const getEventList = (params) => {
    return get('/event/list', params)
}
// 添加活动 {community_id:"x",title:"xxx",probability:"10",draw_time:'xxxx-xx-xx xx:xx:xx'}
export const addEvent = (data) => {
    return post('/event/add', data)
}
// 修改活动 {id:'y',community_id:"x",title:"xxx",probability:"10",draw_time:'xxxx-xx-xx xx:xx:xx'}
export const updateEvent = (data) => {
    return post('/event/update', data)
}
// 开始活动 {id:"x"}
export const startEvent = (data) => {
    return post('/event/start', data)
}
// 抽取活动中奖名单 {id:"x"}
export const drawWinner = (data) => {
    return post('/event/draw', data)
}
// 抽取活动中奖名单 {id:"x"}
export const drawAll = (data) => {
    return post('/event/drawAll', data)
}
// 获取活动中奖名单 {id:"x"}
export const winnerList = (params) => {
    return get('/event/winnerList', params)
}
// 一键重置
export const resetAll = (params) => {
    return get('/event/resetAll', params)
}